<HTML>
    <HEAD>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>进程信息测试页面</title>
  <script type="text/javascript" src="./js/service.js"></script>
  <script type="text/javascript" src="/usr/share/javascript/jquery/jquery.min.js"></script>
  <script src="./js/qwebchannel.js"></script>
      <TITLE>进程信息测试页面</TITLE>
      <SCRIPT language=JavaScript>
              var websocket_url = 'ws://localhost:12345';
              var websocket = null;

              if (websocket === null) {
                  websocket = new WebSocket(websocket_url);
                  websocket.onopen = function () {
                      console.log("connect websocketserver success");
                  }
              } else {
                  websocket.close();
                  websocket = null;
              }

              function getProcInfoCpuUsage() {
                  console.log("getProcInfoCpuUsage")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoCpuUsage(pid);
                          }
                      );
              }
              function getProcInfoIoUsage() {
                  console.log("getProcInfoIoUsage")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoIoUsage(pid);
                          }
                      );
              }
              function getProcInfoMemUsage() {
                  console.log("getProcInfoMemUsage")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoMemUsage(pid);
                          }
                      );
              }
              function getProcInfoStatus() {
                  console.log("getProcInfoStatus")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoStatus(pid);
                          }
                      );
              }
              function getProcInfoPort() {
                  console.log("getProcInfoPort")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoPort(pid);
                          }
                      );
              }
              function getProcInfoStartTime() {
                  console.log("getProcInfoStartTime")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoStartTime(pid);
                          }
                      );
              }
              function getProcInfoRunningTime() {
                  console.log("getProcInfoRunningTime")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoRunningTime(pid);
                          }
                      );
              }
              function getProcInfoCpuTime() {
                  console.log("getProcInfoCpuTime")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoCpuTime(pid);
                          }
                      );
              }
              function getProcInfoCmd() {
                  console.log("getProcInfoCmd")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoCmd(pid);
                          }
                      );
              }
              function getProcInfoUser() {
                  console.log("getProcInfoUser")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfoUser(pid);
                          }
                      );
              }
              function getProcInfo() {
                  console.log("getProcInfo")
                  vid = $("#vid").val()
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getProcInfo(vid);
                          }
                      );
              }

              function getAllProcInfo() {
                  console.log("getAllProcInfo")
                  new QWebChannel(websocket,function(channel){
                          var process = channel.objects.process;
                          process.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          process.getAllProcInfo();
                          }
                      );
              }

        //-->
      </SCRIPT>
      <META content="MSHTML 6.00.2900.6287" name=GENERATOR>
      <style>
        table tr td{padding: 5px;}
      </style>
  
    </HEAD>
    <BODY>
      <div style="margin:30 5 20 5">
        <div>
            <input onclick="getProcInfoCpuUsage()" type="button" value="CPU瞬时使用率"  style="width: 120px; height: 50px">
            <input onclick="getProcInfoIoUsage()" type="button" value="实时网速"  style="width: 120px; height: 50px">
            <input onclick="getProcInfoMemUsage()" type="button" value="内存占用率"  style="width: 100px; height: 50px">
            <input onclick="getProcInfoStatus()" type="button" value="进程状态"  style="width: 100px; height: 50px">
            <input onclick="getProcInfoPort()" type="button" value="进程使用的端口号"  style="width: 120px; height: 50px">
            <input onclick="getProcInfoStartTime()" type="button" value="进程的启动时间"  style="width: 120px; height: 50px">
            <input onclick="getProcInfoRunningTime()" type="button" value="进程的运行时间"  style="width: 120px; height: 50px">
            <input onclick="getProcInfoCpuTime()" type="button" value="CPU时间"  style="width: 100px; height: 50px">
            <input onclick="getProcInfoCmd()" type="button" value="cmd"  style="width: 100px; height: 50px">
            <input onclick="getProcInfoUser()" type="button" value="属主"  style="width: 120px; height: 50px">
            <input onclick="getAllProcInfo()" type="button" value="系统中所有进程信息"  style="width: 120px; height: 50px">
        </div>
        <div id="input_box2">
            <h3>进程号:</h3>
            <label>
              <input type="text" id="pid" style="height: 30px; width: 200px;" placeholder="输入进程号">
            </label>
        </div>  
        <hr style="border: 1px dotted #7633c4; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px">
        <div>
            <input onclick="getProcInfo()" type="button" value="某进程所有信息"  style="width: 120px; height: 50px">
        </div>
        <div id="input_box2">
            <h3>进程名:</h3>
            <label>
              <input type="text" id="vid" style="height: 30px; width: 200px;" placeholder="输入进程名">
            </label>
        </div>
        <div style="margin-top:20">
          <div align=left style="margin:5 0 5 0">回复：</div>
          <div>
          <textarea id="res" style="width:1000px;height:200px" ></textarea>
          </div>
        </div>
      </div>
    </BODY>
  </HTML>
  